package jobs.job3.classloaderdemo.server.standard;

import jobs.job3.classloaderdemo.server.standard.serializer.IOSerializer;

//public interface Task<T,R> extends Function<TaskIn, TaskOut> {
//}

//提交给计算节点的任务必须是该类的子类
public abstract class Task<I, O> {
    public byte[] execute(byte[] input) throws Exception {
        IOSerializer<I, O> IOSerializer = getSerializer();
        I i = IOSerializer.inputDeserialize(input);
        O o = algorithm(i);
        return IOSerializer.outputSerialize(o);
    }

    public abstract O algorithm(I input);//定义业务逻辑

    public abstract IOSerializer<I, O> getSerializer();
}

